package com.ruoyi.web.controller.bookkeeping;

import com.ruoyi.bookkeeping.domain.param.AddBookDynamicReplyParam;
import com.ruoyi.bookkeeping.domain.vo.MsgResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bookkeeping.service.IBookDynamicReplyService;


/**
 * 动态回复Controller
 * 
 * @author ruoyi
 * @date 2023-02-24
 */
@RestController
@RequestMapping("/bookkeeping/reply")
@Api(tags = "动态评论模块")
public class BookDynamicReplyController extends BaseController
{
    @Autowired
    private IBookDynamicReplyService bookDynamicReplyService;

    @Log(title = "动态回复", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增动态回复")
    public MsgResult add(@RequestBody AddBookDynamicReplyParam addBookDynamicReplyParam)
    {
        return MsgResult.toAjax(bookDynamicReplyService.insertBookDynamicReply(addBookDynamicReplyParam,getUserId()));
    }

    @Log(title = "动态回复", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dynamicReplyId}")
    @ApiOperation("删除回复")
    public MsgResult remove(@PathVariable Long dynamicReplyId)
    {
        return MsgResult.toAjax(bookDynamicReplyService.deleteBookDynamicReplyByDynamicReplyId(dynamicReplyId,getUserId()));
    }

    @PutMapping("/goodBookDynamic")
    @ApiOperation("点赞或取消点赞评论")
    public MsgResult goodBookDynamic(Long dynamicReplyId, Long goodOrCancle)
    {
        return MsgResult.toAjax(bookDynamicReplyService.goodBookDynamic(dynamicReplyId,getUserId(),goodOrCancle));
    }
}
